{% extends "orga/schedule/base.html" %}

{% load compress %}
{% load i18n %}
{% load static %}

{% block extra_title %}{% translate "Release new schedule" %} :: {% endblock extra_title %}

{% block schedule_content %}
    <form method="post">
        {% include "common/forms/errors.html" %}
        {% csrf_token %}
        <h2>
            {% translate "Release new schedule" %}
            <div class="d-inline-block">
                {{ form.version.as_field_group }}
            </div>
        </h2>
        {% if warnings.unconfirmed or warnings.unscheduled or warnings.no_track or warnings.talk_warnings %}
            <div class="alert alert-warning">
                <span></span><span>
                    {% blocktranslate trimmed %}
                        There are still warnings about the release of this schedule. Please review them carefully!
                    {% endblocktranslate %}
                </span>
            </div>
        {% endif %}

        <ul>
            <li>
                {% if request.event.wip_schedule.previous_schedule.version %}
                    {% blocktranslate with prev=request.event.wip_schedule.previous_schedule.version since=request.event.wip_schedule.previous_schedule.published|timesince trimmed %}
                        The previous schedule ({{ prev }}) was released {{ since }} ago.
                    {% endblocktranslate %}
                {% else %}
                    {% translate "This will be the very first schedule release." %}
                {% endif %}
            </li>
            <li>
                {% if notifications %}
                    {% blocktranslate trimmed count count=notifications %}
                        When releasing this new schedule, <strong>one notifications email
                        </strong> can be generated and placed in the outbox, to tell speakers about their
                        session slots.
                    {% plural %}
                        When releasing this new schedule, <strong>{{ count }} notifications emails
                        </strong> can be generated and placed in the outbox, to tell speakers about their
                        session slots.
                    {% endblocktranslate %}
                    <br>
                    {% translate "Email template" %}: <a href="{{ notification_template.urls.base }}">{% translate "New schedule version" %}</a>
                {% else %}
                    {% blocktranslate trimmed %}
                        This schedule release would result in <strong>no notification emails</strong> for
                        speakers.
                    {% endblocktranslate %}
                {% endif %}
            </li>
            {% if warnings.unconfirmed %}
                <li>{% blocktranslate trimmed count count=warnings.unconfirmed %}
                    One session is still <strong>unconfirmed</strong> and will not show up
                    on the public schedule.
                {% plural %}
                    {{ count }} sessions are still <strong>unconfirmed</strong> and will not show up
                    on the public schedule.
                {% endblocktranslate %} <a href="{{ request.event.orga_urls.submissions }}?state=accepted&state=pending_state__accepted&state=pending_state__confirmed">{% translate "See all unconfirmed sessions." %}</a></li>
            {% endif %}
            {% if warnings.unscheduled %}
                <li>{% blocktranslate trimmed count count=warnings.unscheduled %}
                    One session has <strong>not yet been scheduled</strong>.
                {% plural %}
                    {{ count }} sessions have <strong>not yet been scheduled</strong>.
                {% endblocktranslate %}</li>
            {% endif %}
            {% if warnings.no_track %}
                <li>{% blocktranslate trimmed count count=warnings.no_track|length %}
                    One session has <strong>not yet been assigned a track</strong>.
                {% plural %}
                    {{ count }} sessions have <strong>not yet been assigned a track</strong>.
                {% endblocktranslate %}
                    <ul>
                        {% for talk in warnings.no_track %}
                            <li><a href="{{ talk.submission.orga_url }}">{{ quotation_open }}{{ talk.submission.title }}{{ quotation_close }}</a></li>
                        {% endfor %}
                    </ul>
                </li>
            {% endif %}
        </ul>
        {% if warnings.talk_warnings %}
            <details>
                <summary class="pb-1">
                    <h4 class="d-inline-flex">{{ warnings.talk_warnings|length }} {% translate "Warnings" %}</h4>
                    <hr class="ml-3 mr-3 mt-0 mr-0">
                </summary>
                <ul>
                    {% for talk in warnings.talk_warnings %}
                        {% for warning in talk.warnings %}
                            <li><a href="{{ warning.url }}">{{ quotation_open }}{{ talk.talk.submission.title }}{{ quotation_close }}</a>: {{ warning.message }}</li>
                        {% endfor %}
                    {% endfor %}
                </ul>
            </details>

        {% endif %}

        <details open>
            <summary class="pb-3">
                <div class="d-inline-flex flex-column">
                    <h4>{% translate "Public changelog" %}</h4>
                    {% translate "This is how the new schedule version will appear in the public changelog and in the RSS feed." %}
                    {% translate "You can include a comment here." %}
                </div>
                <hr class="ml-3 mr-3 mt-0 mr-0">
            </summary>

            <div id="fake-changelog">
                <h4>
                    {{ phrases.schedule.version }}  {{ suggested_version }}
                </h4>
                <div class="flex-next-column">
                    {{ form.comment.as_field_group }}
                </div>
                {% include "agenda/changelog_block.html" with schedule=request.event.wip_schedule %}
            </div>
        </details>

        <div class="submit-group" id="release">
            <div class="d-flex align-items-center">
                <a href="{{ request.event.orga_urls.schedule }}" class="btn btn-info btn-lg">
                    {{ phrases.base.back_button }}
                </a>
            </div>
            <div class="d-flex align-items-center justify-content-end" id="notify-speakers-check">
                {{ form.notify_speakers.as_field_group }}
                <button type="submit" class="btn btn-success btn-lg">{% translate "Release" %}</button>
            </div>
        </div>
    </form>

{% endblock schedule_content %}
